/*
 * UTIL.cpp
 *
 *  Created on: Oct 26, 2012
 *      Author: Bhupendra Aole
 */

#include "UTIL.h"
#include <iostream>

 int UTIL::isNode( const char* name, TiXmlNode* pParent ) {
	if ( !pParent )
		return 0;
	if ( strcmp( name, pParent->Value() ) )
		return 0;

	return 1;
}

 int UTIL::getAttribute( TiXmlElement* pElement, const char* attrib, int *value ) {
	TiXmlAttribute* pAttrib = pElement->FirstAttribute();
	if ( strcmp( pAttrib->Name(), attrib ) )
		return 0;

	pAttrib->QueryIntValue( value );
	return 1;
}

 int UTIL::getAttribute( TiXmlElement* pElement, const char* attrib, string *value ) {
	TiXmlAttribute* pAttrib = pElement->FirstAttribute();
	if ( strcmp( pAttrib->Name(), attrib ) )
		return 0;

	value->assign( pAttrib->ValueStr() );
	return 1;
}
